package cn.samir.sudoku.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import cn.samir.sudoku.R;
import cn.samir.sudoku.core.ScaledSudokuView;
import cn.samir.sudoku.core.Sudokus;
import cn.samir.sudoku.util.Utils;

public class HistoryAdapter extends AdapterBase<Sudokus> {

	Context context;

	public HistoryAdapter(Context context) {
		this.context = context;
		
	}

	@Override
	protected View getExView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.item_history, null);
			viewHolder = new ViewHolder();
			viewHolder.ssv = (ScaledSudokuView) convertView.findViewById(R.id.ssv1);
			viewHolder.tv1 = (TextView) convertView.findViewById(R.id.tv1);
			viewHolder.tv2 = (TextView) convertView.findViewById(R.id.tv2);
			viewHolder.tv3 = (TextView) convertView.findViewById(R.id.tv3);
			convertView.setTag(viewHolder);
		}else{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		Sudokus sudokus = (Sudokus) getItem(position);
		viewHolder.ssv.setContainsId(false);
		viewHolder.ssv.setContent(sudokus.content);
		
		viewHolder.tv1.setText("初盘编号:"+sudokus.sudokuid);
		int score = sudokus.score;
		int getscore = Utils.getSocre(score);
		viewHolder.tv2.setText("难度值："+score+" 本题得分： "+getscore);
		viewHolder.tv3.setText("完成时间："+sudokus.time+"秒");
		return convertView;
	}

	@Override
	protected void onReachBottom() {
		// TODO Auto-generated method stub

	}

	class ViewHolder {
		ScaledSudokuView ssv;
		TextView tv1;
		TextView tv2;
		TextView tv3;

	}

}
